home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-17 | 2.8 KB | 113 lines | [TEXT/MPS ] |
-
- include 'ToolEqu.a'
- include 'SysEqu.a'
- include 'QuickEqu.a'
- include 'Traps.a'
-
- IconID EQU -4064
- BadIconID EQU 128
-
- INITInstall PROC EXPORT
- IMPORT SHOWICON7
- IMPORT a_BusDriver:CODE
- IMPORT a_BusDriverEnd:CODE
- IMPORT BusVars:DATA
- IMPORT BusTask:DATA
- IMPORT InitToPrefs:CODE
-
- FirstResByte EQU a_BusDriver ; first resident byte
- LastResByte EQU a_BusDriverEnd ; last resident byte
- VarsAt EQU BusVars
- TaskAt EQU BusTask
- ShiftKeyCode EQU 56 ; key code for Shift key
-
- clr.l DeskHook
- tst.b MBState ; don't install if mouse button is down
- bpl NoInstall ;
-
- btst #(ShiftKeyCode//8),KeyMap+(ShiftKeyCode/8) ; or if shift key is down
- bne NoInstall ;
-
- lea FirstResByte,A0 ; first byte of resident code
- lea LastResByte,A1 ; first byte beyond resident code
- sub.l A0,A1 ; size of resident code
- move.l A1,D1 ; save size later for BlockMove
- move.l D1,D0
-
- _NewPtr ,sys ; make the resident block in System heap
- tst.w d0 ; check for getting an error
- bne.w NoInstall ; got one, blow out
- move.l A0,A2 ; save new location for _BlockMove
-
- subq.l #4,a7
- move.l #'PREF',-(sp)
- move.w #128,-(sp)
- _GetResource
- move.l (sp),d0
- beq.s NoPrefs
- move.l d0,a0
- _HLock
- move.l (a0),a0
- lea VarsAt,a1
- move.l #6,d0 ; length of prefs, hardcoded
- _BlockMove
- move.l (sp),a0
- _HUnlock
- _HPurge
-
- NoPrefs
- addq.l #4,a7
- move.l a2,a1 ; restore a1
- lea FirstResByte,A0 ; set A0 to source
- move.l D1,D0 ; set D0 to size
- _BlockMove
-
- ; a-reg usage from here out:
- ; a0 - points to init segment resident image
- ; a1 - offset calculations, points to stuff to manipulate
- ; a2 - points to resident image in system heap
-
- move.l a1,a2 ; save system block
- lea VarsAt,a1 ; calcuate vars offset
- sub.l a0,a1
- add.l a2,a1 ; get vars address
-
- move.l a1,-(sp) ; call C routine to init
- move.l a1,-(sp) ; 0 and 4 as needed.
- bsr InitToPrefs
- addq.l #8,a7
-
- lea TaskAt,a1
- sub.l a0,a1
- add.l a2,a1
-
- move.w #vType,qType(a1) ; preserve a1 in case we need to uninstall
- move.w #1,vblCount(a1)
- clr.w vblPhase(a1)
- move.l a2,vblAddr(a1)
-
- move.l a1,a0
- _VInstall
- tst.w d0
- bne.s RemoveNoInstall
-
- ExitInit
- move.l #$50FF8001,$0 ; Finder demands this, don't know why.
- move.w #IconID,-(sp) ; ICN# ID of happy icon
- move.w #$ffff, -(sp) ; tell it to advance
- bsr SHOWICON7 ;
- rts
-
- RemoveNoInstall
- move.l A2,A0 ; dispose of our memory in case of error
- _DisposPtr
- NoInstall
- move.w #BadIconID,-(sp) ; ICN# ID of unhappy icon
- move.w #$ffff, -(sp) ; tell it to advance
- bsr SHOWICON7 ;
- rts
-
- ENDP
- END
-
-